<template>
  <view class="bg-eee pt-3">
    <view class="m-3 mt-0 p-3 py-2 bg-fff rounded15 d-flex d-flex-between ">
      <text>已成功邀请人数</text>
  <text class="font32 mr-2">{{List.count}}</text>
    </view>

    <view class="mx-3 p-3 py-2 bg-fff rounded15 d-flex d-flex-between ">
      <text>已邀请人数消费金额</text>
      <text class="font32 mr-2">{{List.amount}}</text>
    </view>

    <view class="m-3 p-3 py-2 bg-fff rounded15 d-flex d-flex-between" @click="goUrl('/subPages/inviteList/inviteList')">
      <text>分享记录</text>
      <text class="iconfont icon-youjiantou color999 mr-1"></text>
    </view>

    <image mode="widthFix" src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/ch/20542_22_437.png"></image>

    <view class="bg-fff d-flex d-flex-between font24 py-3 px-2 d-flex-middle pb-5 fixedBtn data-v-bf297d2f">
      <button style="border: none;background-color: #ff0000;width: 100%;" data-name="shareBtn"
              class="d-flex d-flex-center d-flex-column d-flex-middle shareBtn rounded20 py-1" open-type="share">
        <text class="font26 colorfff">立即分享</text>
      </button>
    </view>

  </view>
</template>

<script>
import {
  mapState
} from "vuex"
import {
  fileApi,
} from "@/http/fileApi"

export default {
  data() {
    return {
      List: {},
    }
  },
  computed: {
    ...mapState({
      loginState: state => state.loginState,
    })
  },
  onLoad() {
    this.init()
  },
  onShareTimeline(res) {
    return {
      title: 'ch梦电竞小程序',
      path: `/pages/index/index?invite=ch_${this.user_id}`,
      imageUrl:'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/basicprofile.png'
    }
  },
  onShareAppMessage(res) {
    return {
      title: 'ch梦电竞小程序',
      path: `/pages/index/index?invite=ch_${this.user_id}`,
      imageUrl:'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/basicprofile.png'
    }
  },
  methods: {
   async init(){
      let res = await fileApi.getInviteCount()
      this.List = res
    },
    goUrl(urlPages) {
      if (!this.loginState) {
        uni.showToast({
          title: '未登录，请先登录！',
          icon: 'none'
        })
        setTimeout(() => {
          uni.navigateTo({
            url: '/pages/login/login'
          })
        }, 1500)
      } else {
        console.log(urlPages,'urlPages')
        uni.navigateTo({
          url: urlPages
        })
      }
    },
  }
}
</script>

<style>
.py-3 {
  padding-top: 30rpx;
  padding-bottom: 30rpx;
}

.font24 {
  font-size: 24rpx;
}
.fixedBtn {
  position: fixed;
  bottom: 10rpx;
  padding-bottom: 60rpx;
  width: calc(100% - 40rpx);
}
</style>
